<template>
  <div>
    <!-- 搜索框 -->
    <div class="search">
      <div class="bx">
        <input type="text" placeholder="输入商家、商品名称" />
      </div>
      <!-- 轮播图 -->
      <div class="bg">
        <van-swipe class="my-swipe" :autoplay="2000" indicator-color="white">
          <van-swipe-item v-for="(item, index) in list" :key="index">
            <img :src="item.bannerUrl" alt="" />
          </van-swipe-item>
        </van-swipe>
      </div>

      <!-- 猜你喜欢 -->
      <div class="list">
        <div class="xh">
          <span>猜你喜欢</span>
        </div>
        <div class="px">
          <span v-for="(item, index) in pxArr" :key="index">{{ item }}</span>
        </div>
        <div class="rm">
          <span v-for="(item, index) in rmArr" :key="index">{{ item }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { banner_list } from "../utils/api";
export default {
  data() {
    return {
      pxArr: ["综合排序", "距离最近", "销量最高", "筛选"],
      rmArr: ["年货节热卖", "津贴联盟", "满减优惠", "品质联盟"],
      list: [],
    };
  },
  mounted() {
    banner_list().then((res) => {
      //   console.log(res.data);
      this.list = res.data.list;
    });
  },
};
</script>

<style lang='scss' scoped>
.search .bx {
  background: skyblue;
  height: 50px;
  padding: 10px;
  box-sizing: border-box;
  input {
    height: 30px;
    outline: none;
    border: none;
    width: 100%;
    text-align: center;
    border-radius: 50px;
  }
}

.search .bg {
  padding: 10px;
  .my-swipe {
    height: 100px;
    img {
      width: 100%;
    }
  }
}

.list {
  padding: 10px;
  .xh {
    font-size: 18px;
    font-weight: bold;
    padding-bottom: 10px;
  }
  .px {
    display: flex;
    justify-content: space-between;
    padding-bottom: 10px;
  }
  .rm {
    padding-bottom: 20px;
    display: flex;
    justify-content: space-between;
    span {
      background: #f5f5f5;
      padding: 5px 10px;
      font-size: 14px;
      border-radius: 5px;
    }
  }
}
</style>